/*
Copyright 2011, CSE Shareware Foundation
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.
 * Neither the name of CSE Shareware Foundation nor the names of its contributors 
   may be used to endorse or promote products derived from this software without 
   specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _CSESUPER_H_CSEAPI_
#define _CSESUPER_H_CSEAPI_

#include "MngCseApi.h"

extern CSE_IMPEXP_IN TCseObj SARG();
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14);
extern CSE_IMPEXP_IN TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14,const TCseObj& arg15);

class _TSelector;
class _TEntity;
class SClosure;

extern CSE_IMPEXP_IN CseObj CseSuper_unknown;
extern CSE_IMPEXP_IN _TEntity *CseSuper_UnknownObj;
extern CSE_IMPEXP_IN _TEntity CseSuper_EntityAttr(const _TEntity& obj, const TCseObj& attr, 
                     TBool checkErr, int BaseOff=0, TInt *pOffset=NULL, TInt *pIsEntity=NULL);

// _TEntity is scriptable Super-object
class CSE_IMPEXP_IN _TEntity: public TCseObj
{
private:
    TCseObj& operator[](int index) const;  // disable, avoid mistake with TCseObj::operator[]

    TBool isThisCall(TInt& RetId, TInt& DefNum, TInt& VaNum, TBool& isType, TInt iInput) const;

public:
    _TEntity(const _TEntity& obj): TCseObj(obj.m_data) { }

    class m { public:
      TCseObj Id_;
      TCseObj value;
    };

    m *operator->() const {
        ASSERT_TRUE(Cse_type(m_data) == dtBuff && Cse_len(m_data) == 2 && Cse_OptionOn(m_data->bValue[0],16));
        return (m*) m_data->bValue;
    }

public:
    _TEntity();
    _TEntity(CseObj obj);

    _TEntity& operator=(const _TEntity& obj);
    _TEntity& operator=(const SClosure& obj);

    TBool operator==(const _TEntity& obj) const;
    TBool operator==(CseObj obj) const;
    TBool operator!=(const _TEntity& obj) const;
    TBool operator!=(CseObj obj) const;

    _TEntity operator[](const TXchar* attr) const;
    _TEntity operator[](const TCseObj& attr) const;

    TCseObj operator()() const;
    TCseObj operator()(const TCseObj& arg0) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14) const;
    TCseObj operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14,const TCseObj& arg15) const;

    TIntObj eid() const;
    TIntObj has(const TCseObj& Attr) const;
    void exit() const;

    _TEntity bind(const TCseObj& EventName, const _TEntity& fn) const;
    _TEntity unbind(const TCseObj& EventName, const _TEntity& fn = *CseSuper_UnknownObj) const;
    _TEntity trigger(const TCseObj& EventName, const TCseObj& args = CseEmptyBuff) const;

    TCseObj call(const TCseObj& bArgs = CseEmptyBuff) const;                           // system reserved
    TCseObj apply(const TCseObj& This, const TCseObj& bArgs = CseEmptyBuff) const;     // system reserved
    _TEntity each(const _TEntity& EachFunc, const TCseObj& args = CseEmptyBuff) const; // system reserved

    void IntInit(const TCseObj& value = CseEmptyInt) const;
    void WintInit(const TCseObj& value = CseEmptyWint) const;
    void FloatInit(const TCseObj& value = CseEmptyFloat) const;
    void StrInit(const TCseObj& value = CseEmptyStr) const;
    void TierInit(const TCseObj& value = CseEmptyTier) const;
    void BuffInit(const TCseObj& value = CseEmptyBuff) const;
    void DictInit(const TCseObj& value = CseEmptyDict) const;
    void ObjInit(const TCseObj& value = CseEmptyInt) const;
};

extern CSE_IMPEXP_IN TBool operator==(CseObj obj1, const _TEntity& obj2);
extern CSE_IMPEXP_IN TBool operator!=(CseObj obj1, const _TEntity& obj2);

class CSE_IMPEXP_IN TEntityType: public TCseObj
{
public:
    class m { public:
      TCseObj Id_;
      TCseObj value;
    };

    m *operator->() const {
        ASSERT_TRUE(Cse_type(m_data) == dtBuff && Cse_len(m_data) == 2); 
        return (m*) m_data->bValue;
    }

    TEntityType(const _TEntity& obj);
    TEntityType(const TEntityType& obj);

    TEntityType(const TMngStr& name, const TMngInt& size);

    TEntityType addMemb(const TMngStr& attr, const TMngStr& type, const TMngInt& offset) const;
    TEntityType addFunc(const TMngStr& attr, const TMngInt& offset, const TMngStr& sArgs, const TCseObj& bDefault = CseEmptyBuff) const;
    TEntityType addProt(const TMngStr& attr, const TMngInt& addr, const TMngStr& sArgs, const TMngStr& type = CseEmptyStr, const TCseObj& bDefault = CseEmptyBuff, TBool ClsStatic = false) const;
};

class CSE_IMPEXP_IN _TArray: public TCseObj
{
private:
    TCseObj& operator[](int index) const;  // disable, avoid mistake with operator()

public:
    class m { public:
      TCseObj Id_;
      TMngBuff bItems;
    };

    m *operator->() const {
        ASSERT_TRUE(Cse_type(m_data) == dtBuff && Cse_len(m_data) == 2 && Cse_OptionOn(m_data->bValue[0],16)); 
        return (m*) m_data->bValue;
    }

public:
    _TArray(const _TArray& obj);

    _TEntity operator()(const TMngInt& index, const TCseObj& value = dummy) const;

    TIntObj push(const TCseObj& value, const TCseObj& args = CseEmptyBuff) const;
    _TEntity pop(const TMngInt& index = -1) const;
    _TEntity shift() const;
    TIntObj unshift(const TCseObj& value, const TCseObj& args = CseEmptyBuff) const;
    _TEntity sliceOf(const TMngInt& index, const TMngInt& iLen = -1) const;

    TCharArray desc(const TMngStr& separator = _T(",")) const;
    _TEntity concat(const _TEntity& that) const;
    _TEntity reverse() const;
    _TEntity splice(const TMngInt& iStart,const TMngInt& iDelNum = -1,const TCseObj& args=CseEmptyBuff) const;
};

class CSE_IMPEXP_IN _TLinker: public TCseObj
{
private:
    TCseObj& operator[](int index) const;  // disable, avoid mistake with TCseObj::operator[]

public:
    _TLinker();
    _TLinker(const _TLinker& linker);

    _TLinker& operator=(const _TLinker& obj);
    _TEntity operator()(const TMngInt& root = 0) const;
};

class CSE_IMPEXP_IN _TSelector: public TCseObj
{
private:
    TCseObj& operator[](int index) const;  // disable, avoid mistake with operator()

public:
    _TSelector(CseObj obj): TCseObj(obj) { ASSERT_TRUE(Cse_type(obj) == dtBuff && Cse_len(obj) == 2); }
    _TSelector(const _TSelector& obj): TCseObj(obj.m_data) { }

    class m { public:
      TCseObj Id_;
      TMngBuff bItems;
    };

    m *operator->() const {
        ASSERT_TRUE(Cse_type(m_data) == dtBuff && Cse_len(m_data) == 2); 
        return (m*) m_data->bValue;
    }
    
    TBool enumItem(void*& pIter, TCseObj *pRet=NULL) const
    { return self->bItems.bArray().enumItem(pIter,pRet); }

public:
    _TSelector();
    _TSelector(const TMngInt& index);
    _TSelector(const TXchar *selector, TInt from = 0, TInt num = -1, TInt to = -1);

    _TEntity operator()(const TMngInt& i) const;

    void init(const TCseObj& SQL = dummy, const TMngInt& from = 0, const TMngInt& num = -1, const TMngInt& to = -1) const;

    _TSelector join(const _TSelector& other) const;

    _TSelector exit() const;
    _TSelector reset(const TCseObj& SQL, const TMngInt& from = 0, const TMngInt& num = -1, const TMngInt& to = -1) const;
    _TSelector filter(const _TEntity& FilterFunc, const TCseObj& args = CseEmptyBuff) const;
    _TSelector each(const _TEntity& EachFunc, const TCseObj& args = CseEmptyBuff) const;

    _TSelector bind(const TCseObj& EventName, const _TEntity& fn) const;
    _TSelector unbind(const TCseObj& EventName, const _TEntity& fn = *CseSuper_UnknownObj) const;
    _TSelector trigger(const TCseObj& EventName, const TCseObj& args = CseEmptyBuff) const;
};

namespace __S
{
    extern CSE_IMPEXP_IN _TEntity E(const TMngInt& eid);

    extern CSE_IMPEXP_IN _TEntity e(const TMngStr& selector, const TMngInt& NoCache = 0);
    extern CSE_IMPEXP_IN _TEntity t(const TMngStr& name = CseEmptyStr);
    extern CSE_IMPEXP_IN _TEntity f(const TMngInt& addr, const TMngStr& sArgs, const TCseObj& bDefault = CseEmptyBuff);
    extern CSE_IMPEXP_IN _TEntity f(const TMngInt& addr, TInt ArgNum, TXchar RetFlag, const TCseObj& bDefault = CseEmptyBuff);

    extern CSE_IMPEXP_IN TCseObj parseInt(const TCseObj& value, const TMngInt& radix = 10);
    extern CSE_IMPEXP_IN TCseObj parseFloat(const TCseObj& value);
    extern CSE_IMPEXP_IN TIntObj isNaN(const TCseObj& value);

    extern CSE_IMPEXP_IN TIntObj cachedNum();
    extern CSE_IMPEXP_IN _TEntity rootEntity();
    extern CSE_IMPEXP_IN _TLinker linkTo(const TXchar* attr);
    extern CSE_IMPEXP_IN _TLinker linkTo(const TCseObj& attr);
}

extern CSE_IMPEXP_IN int CseSuper_len(const TCseObj& obj);
extern CSE_IMPEXP_IN int CseSuper_AddOnNew(const _TEntity& callback);
extern CSE_IMPEXP_IN void (*CseSuper_AfterExit)(const TCseObj& b);

extern CSE_IMPEXP_IN TCseObj CseSuper_NewArr(const TXchar *TypeName, const TXchar *ItemType, int dim = 1);
extern CSE_IMPEXP_IN TCseObj CseSuper_NewUdt(const TCseObj& TypeName, TInt size);
extern CSE_IMPEXP_IN void CseSuper_AddMemb(const TCseObj& bUdt, const TXchar *Attr, const TXchar *Type, TInt offset);
extern CSE_IMPEXP_IN void CseSuper_AddFunc(const TCseObj& bUdt, const TXchar *Attr, TInt addr, const TXchar *sArgs, const TCseObj& bDefault = CseEmptyBuff);
extern CSE_IMPEXP_IN void CseSuper_AddProt(const TCseObj& bUdt, const TXchar *Attr, TInt addr, const TXchar *sArgs, const TXchar *Type = NULL, const TCseObj& bDefault = CseEmptyBuff, TBool ClsStatic = false);

class CSE_IMPEXP_IN _TMngUdt: public TCseObj
{
protected:
    _TMngUdt(): TCseObj(CseEmptyBuff) { }
    _TMngUdt(CseObj data): TCseObj(data)
    { if (Cse_type(m_data) != dtBuff) throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("content of _TMngUdt should be dtBuff")); }

    void resize(int iSize) const { bArray().resize(iSize); }

public:
    class m {
    };
};

class CSE_IMPEXP_IN SClosure: public TCseObj
{
private:
    SClosure();  // disable default constructor

public:
    SClosure(const _TEntity& func, const TCseObj& env);
    SClosure(const SClosure& obj);

    TCseObj operator()(const TCseObj& args = CseEmptyBuff) const;
};

#define CLOSURE_ARG_BEGIN()        class __closure_arg: public TCseObj { public: class m { public:
#define CLOSURE_ARG_END(name)      }; \
                                   __closure_arg(): TCseObj(CseEmptyBuff) { \
                                       int iLen = sizeof(m) / sizeof(CseObj); \
                                       bArray().resize(iLen); \
                                       m obj; CseObj *pSour = (CseObj *) &obj; \
                                       for (int i = 0; i < iLen; i++,pSour++) sub(i) = *pSour; \
                                   } \
                                   m *operator->() const { return (m*) m_data->bValue; } \
                                   } name;

#define CLOSURE_ARG_FROM(name,args) }; \
                                   __closure_arg(const TCseObj& obj): TCseObj(obj) { \
                                       ASSERT_TRUE(Cse_type(m_data) == dtBuff); \
                                    } \
                                   m *operator->() const { return (m*) m_data->bValue; } \
                                   } name(args.pop());

#ifndef MNG_OPEN_NEWDEL
  #define MNG_SUPER_BEGIN(AClass,ABase)   \
    private: static void* operator new(size_t); \
      static void* operator new(size_t,int); \
      static void operator delete(void*); \
      static void operator delete(void*,size_t); \
    public: \
      AClass(CseObj obj): ABase(obj) { } \
      AClass(const AClass& obj): ABase(obj.m_data) { } \
      AClass(const _TEntity& en): ABase((CseObj)en->value) { } \
      AClass& operator=(const _TEntity& en) { *(TCseObj*)this = en->value; return *this; } \
      class m_ { public:
#else
  #define MNG_SUPER_BEGIN(AClass,ABase)   \
    public: \
      AClass(CseObj obj): ABase(obj) { } \
      AClass(const AClass& obj): ABase(obj.m_data) { } \
      AClass(const _TEntity& en): ABase((CseObj)en->value) { } \
      AClass& operator=(const _TEntity& en) { *(TCseObj*)this = en->value; return *this; } \
      class m_ { public:
#endif

#define MNG_SUPER_END(AClass,ABase)  }; \
    class m: public ABase::m, public m_ { private: m(); m(const m& obj); }; \
    m *operator->() const { return (m*) m_data->bValue; } \
    void __init__() { \
        int iLen = sizeof(m) / sizeof(CseObj); \
        if (len() < iLen) ABase::resize(iLen); \
        m_ obj; int iLen_ = sizeof(obj) / sizeof(CseObj); \
        CseObj *pSour = (CseObj *) &obj; \
        for (int i = iLen - iLen_; i < iLen; i++,pSour++) sub(i) = *pSour; \
    }

#endif

#ifndef NO_CSESUPER_PREFIX
  #define SLEN                     CseSuper_len
  #define undefined                CseSuper_unknown

  typedef _TSelector  _S;
  typedef _TLinker    _SLinker;

  typedef TMngInt     SInt;
  typedef TMngWint    SWint;
  typedef TMngFloat   SFloat;
  typedef TMngStr     SStr;
  typedef TMngTier    STier;
  typedef TMngBuff    SBuff;
  typedef TMngDict    SDict;
  typedef TCseObj     SObject;
#endif
